package com.hmall.order.interceptors;

import com.hmall.order.utils.ThreadLocal4UserId;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Author: cuiliangbo
 * @Date: 2022/6/16 11:25
 */
@SuppressWarnings("all")
@Component
@Slf4j
public class MyInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        Long userId = ThreadLocal4UserId.getUserId();

        //打印日志信息
        log.info("userId = {}",userId);

        //设置请求头
        requestTemplate.header("authorization","2");
    }
}
